#include <iostream>
#include <fcntl.h>
#include <unistd.h>
#include "cJSON.h"

using namespace std;
int main() {
    int fd = open("../test.json", O_RDONLY);
    if (fd < 0){
        perror("open");
        return 2;
    }
    char buffer[1024];
    int res;
    if ((res = read(fd, buffer, 1024)) < 0){
        perror("read");
        return 1;
    }
    buffer[res] = '\0';
    printf("%s\n", buffer);
    auto cjson = cJSON_Parse(buffer);
    printf("%d\n", cjson->type == cJSON_Object);
    cjson = cjson->child;
    while(cjson){
        printf("%s\n", cjson->string);
        cjson = cjson->next;
    }
}
